/**
 * 
 */
package com.hz.winnie.demands.web.controller;

import static com.hz.winnie.demands.common.DemandsConstants.COOKIE_KEY_DEM_USER;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.hz.winnie.demands.common.DemandsConstants;
import com.hz.winnie.demands.utils.CookieUtils;

/**
 * @description 登出
 * @author winnie
 * @date 2011-4-21
 * @version 1.0
 */
@Controller
@RequestMapping("/")
public class LogoutController {

    @Autowired
    private HttpSession session;

    @RequestMapping("/logout")
    public String logout(Model model, HttpServletResponse response,
	    HttpServletRequest request) {
	// 清除cookie
	CookieUtils.setCookie(request, response,
		DemandsConstants.COOKIE_KEY_DEM_ID, null);
	// 清除Session
	session.setAttribute(DemandsConstants.SESSION_KEY_USER, null);
	model.addAttribute(COOKIE_KEY_DEM_USER, null);
	return "redirect:/login.htm";
    }
}
